import request from '@/utils/request'

export function fetchStoreList(params) {
  return request({
    url: '/api/stores/page',
    method: 'get',
    params
  })
}

export function getStoreById(id) {
  return request({
    url: `/api/stores/${id}`,
    method: 'get'
  })
}

export function createStore(data) {
  return request({
    url: '/api/stores',
    method: 'post',
    data
  })
}

export function updateStore(id, data) {
  return request({
    url: `/api/stores/${id}`,
    method: 'put',
    data
  })
}

export function deleteStore(id) {
  return request({
    url: `/api/stores/${id}`,
    method: 'delete'
  })
}

// 获取附近门店
export function getNearbyStores(latitude, longitude, limit = 10) {
  return request({
    url: '/api/stores/nearby',
    method: 'get',
    params: {
      latitude,
      longitude,
      limit
    }
  })
}

// 上传门店图片
export function uploadStoreImage(data) {
  return request({
    url: '/api/upload',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}